package cn.whitecao.contentcenter.controller;

import cn.whitecao.contentcenter.annotations.MyAnnotation;
import cn.whitecao.contentcenter.domain.dto.content.ShareDTO;
import cn.whitecao.contentcenter.domain.dto.user.UserDTO;
import cn.whitecao.contentcenter.service.ShareService;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/shares")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class ShareConroller {
    private final ShareService shareService;

    @MyAnnotation
    @GetMapping("/{id}")
    @SentinelResource("findById")
    public ShareDTO findById(@PathVariable Integer id) {
        return this.shareService.findById(id);
    }


    @GetMapping("queryTest")
    public UserDTO query(UserDTO userDTO){
        return shareService.queryTest(userDTO);
    }
}
